package core.domain;

import javax.persistence.EntityManager;

import org.springframework.orm.jpa.JpaCallback;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.stereotype.Repository;

@Repository
public abstract class SimpleDao {

	private EntityManager em = null;

	public EntityManager getEm() {
		return em;
	}

	public void setEm(EntityManager em) {
		this.em = em;
	}

	private JpaTemplate getJpaTemplate() {
		return new JpaTemplate(em);
	}

	public <T> T execute(JpaCallback<T> action) {
		return getJpaTemplate().execute(action);
	}
}
